package bsc.war.ajax;

import bsc.ejb.entity.ScoreCard;
import bsc.ejb.metadata.NoteType;
import bsc.war.delegate.DelegateBSC;
import bsc.war.factory.Factory;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

/**
 *
 * @author memozac
 */
public class AddNote extends AbstractController {

    @Override
    protected ModelAndView handleRequestInternal(HttpServletRequest request,
            HttpServletResponse response) throws Exception {

        ModelAndView mav = new ModelAndView("addNote");
        DelegateBSC delegate = (DelegateBSC) Factory.getBean("DelegateBSC");

        //if(NumberUtils.isDigits(request.getParameter("idScoreCard"))){
        ScoreCard scoreCard = delegate.findScoreCard(Long.parseLong(request.getParameter("scoreCard")));
        List<NoteType> noteTypes = delegate.findNoteType();

        System.out.println("Subi el ScoreCard: " + scoreCard.getName());
        mav.addObject("scoreCard", scoreCard);
        mav.addObject("noteTypes", noteTypes);
        //}

        return mav;
    }
}
